// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: listener code decoupling
// feature: agent for vbs
// feature: destination order support by reception timestamp
// feature: simplify xml profile
// feature: E2E Profile04 and Configuration Function Development
// ------------------------------------------------------------------

#ifndef XMLPARSER_READERQOS_HPP_
#define XMLPARSER_READERQOS_HPP_

#include <xmlparser/qos/XMLQosPolicies.hpp>

namespace vbsutil {
namespace xmlparser {

/**
 * Class ReaderQos, contains all the possible Qos that can be set for a determined Subscriber.
 * Although these values can be set and are transmitted
 * during the Endpoint Discovery Protocol, not all of the behaviour associated with them has been
 * implemented in the library. Please consult each of them to check for implementation details and
 * default values.
 * @ingroup ERTPS_ATTRIBUTES_MODULE
 */
class ReaderQos : public BaseReaderQos {
 public:
    RTPS_DllAPI ReaderQos() {}

    RTPS_DllAPI virtual ~ReaderQos() {}

    bool operator==(const ReaderQos& b) const {
        return (m_durability == b.m_durability) && (m_deadline == b.m_deadline) && (m_liveliness == b.m_liveliness) &&
               (m_reliability == b.m_reliability) && (m_ownership == b.m_ownership) && (m_partition == b.m_partition) &&
               (m_lifespan == b.m_lifespan) && (m_disablePositiveACKs == b.m_disablePositiveACKs) &&
               (m_e2eProtecion == b.m_e2eProtecion) && (this->m_resourceLimits == b.m_resourceLimits) &&
               (this->m_history == b.m_history) && (this->m_isMultiSend == b.m_isMultiSend) &&
               (m_destinationOrder == b.m_destinationOrder) && (m_ipc_mode == b.m_ipc_mode) &&
               (m_agent_flag == b.m_agent_flag);
    }

    //! Durability Qos, implemented in the library.
    DurabilityQosPolicy m_durability;

    //! Deadline Qos, implemented in the library.
    DeadlineQosPolicy m_deadline;

    //! Liveliness Qos, implemented in the library.
    LivelinessQosPolicy m_liveliness;

    //! ReliabilityQos, implemented in the library.
    ReliabilityQosPolicy m_reliability;

    //! Ownership Qos, implemented in the library.
    OwnershipQosPolicy m_ownership;

    //! Partition Qos, implemented in the library.
    PartitionQosPolicy m_partition;

    LifespanQosPolicy m_lifespan;

    //! Disable positive ACKs QoS
    DisablePositiveACKsQosPolicy m_disablePositiveACKs;

    //! E2E Protection QoS implemented in the library.
    E2EProtectionQosPolicy m_e2eProtecion;

    bool m_isMultiSend = false;

    uint8_t m_ipc_mode = 0;

    uint8_t m_agent_flag = 0;

    HistoryQosPolicy m_history;

    ResourceLimitsQosPolicy m_resourceLimits;

    //!Destinatio Order Qos
    DestinationOrderQosPolicy m_destinationOrder;

    /**
     * Set Qos from another class
     * @param qos Reference from a ReaderQos object.
     * @param first_time Boolean indicating whether is the first time (If not some parameters cannot
     * be set).
     */
    RTPS_DllAPI void setQos(const ReaderQos& qos, bool first_time);

    /**
     * Check if the Qos can be update with the values provided. This method DOES NOT update
     * anything.
     * @param qos Reference to the new qos.
     * @return True if they can be updated.
     */
    RTPS_DllAPI bool canQosBeUpdated(const ReaderQos& qos) const;

    void clear();
};

}  // namespace xmlparser
}  // namespace vbsutil

#endif  // INCLUDE_EDDS_DDS_SUBSCRIBER_QOS_READERQOS_HPP_
